<?php

namespace Database\Seeders;

use Illuminate\Database\Console\Seeds\WithoutModelEvents;
use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Models\Category;

class CategorySeeder extends Seeder
{
    /**
     * Run the database seeds.
     */
    public function run(): void
    {
        DB::transaction(function () {
            $this->createMainCategories();
            
            $this->command->info('✅ 分类数据创建完成');
        });
    }

    private function createMainCategories()
    {
        $categories = [
            [
                'name' => 'Orange Phone',
                'slug' => 'orange-phone',
                'description' => 'Orange Phone 系列手机，包括最新款 Orange Phone 15 系列',
                'icon' => '📱',
                'is_active' => true,
                'is_featured' => true,
                'sort_order' => 1,
            ],
            [
                'name' => 'Orange Book',
                'slug' => 'orange-book',
                'description' => 'Orange Book 系列电脑，包括 Orange Book Pro、Orange Book Air 等',
                'icon' => '💻',
                'is_active' => true,
                'is_featured' => true,
                'sort_order' => 2,
            ],
            [
                'name' => '配件',
                'slug' => 'accessories',
                'description' => '各种配件和周边产品',
                'icon' => '🔌',
                'is_active' => true,
                'is_featured' => true,
                'sort_order' => 3,
            ],
        ];

        foreach ($categories as $categoryData) {
            Category::create($categoryData);
        }

        $this->command->info('📂 创建了 ' . count($categories) . ' 个主分类');
    }

}